package com.netease.xone.itemview;

import java.util.List;

import protocol.meta.AppInfo;
import protocol.meta.AppInfoDetail;
import protocol.meta.AppWare;
import protocol.meta.AppWareItem;
import Utils.StackTraceUtil;
import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.netease.log.NTLog;
import com.netease.xone.R;


public class RenderDetailWare implements IRenderInfoBase, OnClickListener{
    private static final String TAG = RenderDetailWare.class.getSimpleName();
    
    
    private View mRoot;
    private TextView mTitle;
    private TextView mContent;
    private LinearLayout mList;
    private TextView mItem1;
    private TextView mItem2;

    public RenderDetailWare(View v) {
        mRoot = v;
        
        mTitle = (TextView)v.findViewById(R.id.title);
        mContent = (TextView)v.findViewById(R.id.text);
        mList = (LinearLayout)v.findViewById(R.id.list);
        mItem1 = (TextView)v.findViewById(R.id.item1);
        mItem2 = (TextView)v.findViewById(R.id.item2);
    }

    @Override
    public void renderView(Context context, AppInfo appInfo) {
        
    }

    @Override
    public void renderView(Context context, AppInfoDetail appInfoDetail) {
        
    }
    
    public void renderView(Context context, AppWare appWare) {
        NTLog.d(TAG, StackTraceUtil.getMethodName());
        mTitle.setVisibility(View.GONE);
        mContent.setVisibility(View.GONE);
        mList.setVisibility(View.GONE);
        
        String value = null;
        
        value = appWare.getTitle();
        if (!TextUtils.isEmpty(value)) {
            mTitle.setVisibility(View.VISIBLE);
            mTitle.setText(value);
        }
        
        value = appWare.getDesc();
        if (!TextUtils.isEmpty(value)) {
            mContent.setVisibility(View.VISIBLE);
            mContent.setText(value);
        }
        
        List<AppWareItem> list = appWare.getItemList();
        if (null != list && list.size() > 0) {
            if (!list.get(0).getSelected() && !list.get(1).getSelected()) {
                mList.setVisibility(View.VISIBLE);
                mItem1.setText(list.get(0).getTitle());
                mItem2.setText(list.get(1).getTitle());
            }
        }
    }
    
    @Override
    public void onClick(View v) {
        NTLog.d(TAG, StackTraceUtil.getMethodName());
    }
   
}
